﻿<UserControl x:Class="PocketBook.UI.View.Workspaces.IncomesWorkspaceView"
			 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
			 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
			 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
			 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
			 xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
			 xmlns:conv="clr-namespace:PocketBook.UI.Converters"
			 xmlns:GalaSoft_MvvmLight_Command="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF4" 
			 mc:Ignorable="d">
    <UserControl.Resources>
        <conv:AmountValueConverter x:Key="AmountValueConverter" />
    </UserControl.Resources>
	<Grid>
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto" />
			<RowDefinition Height="*" />
		</Grid.RowDefinitions>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="*" />
		</Grid.ColumnDefinitions>
		<Button Grid.Row="0" Grid.Column="0" Content="Add" HorizontalAlignment="Left" Height="25" Margin="6,6,0,0" VerticalAlignment="Top" Width="80"  Command="{Binding AddIncomeCommand}"/>
		<Button Grid.Row="0" Grid.Column="1" Content="Edit" HorizontalAlignment="Left" Height="25" Margin="6,6,0,0" VerticalAlignment="Top" Width="80"  Command="{Binding EditIncomeCommand}"/>
		<Button Grid.Row="0" Grid.Column="2" Content="Delete" HorizontalAlignment="Left" Height="25" Margin="6,6,0,0" VerticalAlignment="Top" Width="80"  Command="{Binding DeleteIncomeCommand}"/>
		<DataGrid Grid.Row="1" Grid.ColumnSpan="4" Margin="8" ItemsSource="{Binding Path=IncomesList}" SelectedItem="{Binding Path=SelectedIncome}">
			<DataGrid.Columns>
				<DataGridTextColumn Header="Name" Width="360" Binding="{Binding Name}"/>
				<DataGridTextColumn Header="Creation date" Width="200" Binding="{Binding Date}"/>
				<DataGridTextColumn Header="Amount" Width="*" Binding="{Binding Amount, Converter={StaticResource AmountValueConverter}}"/>
			</DataGrid.Columns>
			<i:Interaction.Triggers>
				<i:EventTrigger EventName="MouseDoubleClick">
					<GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding EditIncomeCommand}"/>
				</i:EventTrigger>
			</i:Interaction.Triggers>
		</DataGrid>
	</Grid>
</UserControl>
